using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class Vw_attend_user {
		#region Fields
		private int ehId;
		private int uid;
		private string nick_Name;
		private string pic;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the Vw_attend_user class.
		/// </summary>
		public Vw_attend_user() {
		}
		
		/// <summary>
		/// Initializes a new instance of the Vw_attend_user class.
		/// </summary>
		public Vw_attend_user(int ehId, int uid, string nick_Name, string pic) {
			this.ehId = ehId;
			this.uid = uid;
			this.nick_Name = nick_Name;
			this.pic = pic;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the EhId value.
		/// </summary>
		public int EhId {
			get { return ehId; }
			set { ehId = value; }
		}
		
		/// <summary>
		/// Gets or sets the Uid value.
		/// </summary>
		public int Uid {
			get { return uid; }
			set { uid = value; }
		}
		
		/// <summary>
		/// Gets or sets the Nick_Name value.
		/// </summary>
		public string Nick_Name {
			get { return nick_Name; }
			set { nick_Name = value; }
		}
		
		/// <summary>
		/// Gets or sets the Pic value.
		/// </summary>
		public string Pic {
			get { return pic; }
			set { pic = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the vw_attend_user table.
		/// </summary>
		public void Insert() {
			SqlClientUtility.ExecuteNonQuery("vw_attend_userInsert", ehId, uid, nick_Name, pic);
		}
		
		/// <summary>
		/// Selects all records from the vw_attend_user table.
		/// </summary>
		public static List<Vw_attend_user> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("vw_attend_userSelectAll")) {
				List<Vw_attend_user> vw_attend_userList = new List<Vw_attend_user>();
				while (dataReader.Read()) {
					Vw_attend_user vw_attend_user = MakeVw_attend_user(dataReader);
					vw_attend_userList.Add(vw_attend_user);
				}
				return vw_attend_userList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the vw_attend_user class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static Vw_attend_user MakeVw_attend_user(SqlDataReader dataReader) {
			Vw_attend_user vw_attend_user = new Vw_attend_user();
			
			if (dataReader.IsDBNull(0) == false) {
				vw_attend_user.EhId = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				vw_attend_user.Uid = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				vw_attend_user.Nick_Name = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				vw_attend_user.Pic = dataReader.GetString(3);
			}

			return vw_attend_user;
		}
		#endregion
	}
}
